C This is FORTRAN source code which will compile into
C an xCOD (eXternal CODe) resource for NumberCrunch II.
C
C 
C After building this code resource you must install it into NumberCrunch with either ResEdit or the
C Load xCOD command from inside NCII.
C
C In either case, an sCOD string or resource is also needed to tell NCII what the arguments to this routine are
C     For this routine, an appropriate sCOD is:
C
C    xCOD xSAMPLE_XCODE(J:num; Bj:Array; prog Foo(K:num; Ak:array); Cj:ComplexArray), sets all of Cj[1ÉJ] to 1 + 0i,  Bj[1Éj] to 1Éj, and passes a K=3 element array [3,2,1] to Foo.
C
C   The procedure arguments are}
C       	J		:   extended number}
C        	Bj		:   array of extended}
C        	foo		:   the name of another xCOD or an NCII user program
C		    Cj	:   an array of complex numbers, i.e. a 2J array of extended
C
C
		subroutine SAMPLE_XCOD(zJ, Bj, Foo, Cj)
		implicit extended (a-h, o-z)
		dimension Bj(*), Cj(*), ArrayForFoo(3)
		external Foo
C
C     Convert the array size to an integer.
		J = zJ
C
C     Set the Bj array.
		do i=1,J
		  Bj(i) = 1.0*i
		end do
C
C     Set the (real, complex, real, complex, ...) array Cj to 1 + 0i.
		do i=1,J
		  Cj(2*i-1) = 1.0
		  Cj(2*i) = 0.0
		end do
C
C     Set up the array to pass to the program Foo.
		ArrayForFoo(1) = 3.0
		ArrayForFoo(2) = 2.0
		ArrayForFoo(3) = 1.0
		SizeForFoo = 3.0
C
C     Run the program Foo.
		CALL FOO(SizeForFoo, ArrayForFoo)
C		
		return
		end
